import { Ref, ref } from '@vue/composition-api';
import { Engine } from './engine';
import { cloneDeep } from 'lodash';
import { IAssets, ISetters } from '../shared/types';

export class Workbench {
  engine: Engine;
  assets: IAssets;
  setters: ISetters;
  settersFormInstance: any = null;

  constructor(engine: Engine) {
    this.engine = engine;
    this.assets = {
      components: {},
      menu: []
    };
    this.setters = {}
  }

  updateAssets(assets: IAssets) {
    this.assets = cloneDeep(assets);
  }

  updateSetters(setters: ISetters) {
    this.setters = cloneDeep(setters);
  }
  validateSettersForm() {
    if (this.settersFormInstance) {
      return this.settersFormInstance.validate();
    }
    return Promise.resolve(true);
  }
}
